package Concurrent.countDownLatch.wait.join;

/**
 * Created by wangyg6 on 2017/11/29.
 * 主线程做一个工作，不过要在Task one two结束之后.可以看到Task one two顺序随机
 */
public class JoinDemo {

	public static void main(String[] args) {
		Thread threadOne = new Thread(new TaskOne(), "TaskOne Thread");
		threadOne.start();
		Thread threadTwo = new Thread(new TaskTwo(), "TaskTwo Thread");
		threadTwo.start();
		Thread threadThree = new Thread(new TaskThree(), "TaskThree Thread");
		threadThree.start();
		try {
			Thread.sleep((long) (Math.random() * 1000));
			threadOne.join();
			threadTwo.join();
			threadThree.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("main Thread complete");
	}
}
